package app.auto.designer.tool;

import android.app.SearchManager;
import android.os.SystemClock;
import android.view.View;

import app.auto.runner.base.intf.FunCallback;

public class DoubleClickListener implements View.OnClickListener {

    FunCallback fun;

    public DoubleClickListener(FunCallback fun) {
        this.fun = fun;
        setFun(fun);
    }

    public void setFun(FunCallback fun) {
        this.fun = fun;
    }

    long[] mHits =new long[2];

    public void  onClick(View view){
        //实现数组的位移操作，点击一次，左移一位，末尾补上当前开机时间（cpu时间）
        System.arraycopy(mHits,1,mHits,0,mHits.length-1);
        mHits[mHits.length-1]= SystemClock.uptimeMillis();

        if(500>(SystemClock.uptimeMillis()-mHits[0])){
            //此处执行双击事件
            if(fun!=null){
                fun.simpleRun(view);
            }
        }
    }
}
